package com.tokenmaster.aitrade.init.history_okex;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.LinkedList;
import java.util.Queue;

import org.apache.log4j.Logger;

import com.tokenmaster.aitrade.common.account.Account;
import com.tokenmaster.aitrade.common.system.KLinePoint;
import com.tokenmaster.aitrade.data.SystemDB;
import com.tokenmaster.aitrade.trade.kdj.Index_KDJ;
import com.tokenmaster.aitrade.trade.kdj.Index_KDJ_Info;

public class Create_KDJ {

	private static long unixtime = 0;

	public static void main(String[] args) {

		while (true) {
			try {
				doWork();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

	// 循环执行
	public static void doWork() throws IOException {

		Logger logger = Logger.getLogger(Create_KDJ.class);
		SystemDB systemDB = SystemDB.getInstance();
		Index_KDJ index_KDJ = new Index_KDJ();
		
		// 数据库读取行情
		KLinePoint kLinePoint = systemDB.getKLinePointBack("btc_usdt", "5min", unixtime);
		
		unixtime = kLinePoint.getUnixTime();

		Index_KDJ_Info index_KDJ_Info = index_KDJ.calculation(kLinePoint);
		systemDB.updateIndexKDJInfo(index_KDJ_Info);

		double lastUnixTime = kLinePoint.getUnixTime();
		SimpleDateFormat sformat = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
		String timestr = sformat.format(lastUnixTime);

		logger.info("生成KDJ" + timestr);

	}

}
